var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, i) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var i in e)
              Object.prototype.hasOwnProperty.call(e, i) && (t[i] = e[i]);
          })(e, i);
      };
      return function (e, i) {
        function o() {
          this.constructor = e;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        t(e, i),
          (e.prototype =
            null === i
              ? Object.create(i)
              : ((o.prototype = i.prototype), new o()));
      };
    })(),
  AutoSettingsDialog = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.totalNum = 0),
        e.label_SettingItem1.on(Laya.Event.CLICK, e, e.onSettingItemAction),
        e.label_SettingItem2.on(Laya.Event.CLICK, e, e.onSettingItemAction),
        (e.list_autoSettings.selectEnable = !0),
        (e.list_autoSettings.vScrollBarSkin = ""),
        e.list_autoSettings.on(
          Laya.Event.CLICK,
          e,
          e.onListAutoSettingDidClick
        ),
        e.radio_youxianshiyong.on(
          Laya.Event.CLICK,
          e,
          e.onRadioYouXianShiYongAction
        ),
        e.btn_auto_start.on(Laya.Event.CLICK, e, e.onAutoStartGuaJiAction),
        (e.text_auto_num.restrict = "0-9"),
        WebSocketService.addListener({
          caller: e,
          code: 6102,
          method: e.onLoadVipNumberData,
        }),
        e
      );
    }
    return (
      __extends(e, t),
      (e.showAutoSettingsDialog = function (t) {
        return (
          null == this.autoSettingV &&
            ((this.autoSettingV = new e()), (this.autoSettingV.zOrder = 1e3)),
          this.autoSettingV.popup(!0),
          (this.autoSettingV.list_autoSettings.visible = !1),
          (this.autoSettingV.radio_youxianshiyong.selectedIndex = 0),
          (this.autoSettingV.text_auto_num.text = "10"),
          (this.autoSettingV.dataArr = t),
          this.autoSettingV.initListData(),
          (this.autoSettingV.list_autoSettings.selectedIndex = 0),
          (this.autoSettingV.label_SettingItem1.text = t[0].name),
          WebSocketService.send({ c: 6102, d: { lvl: -2 } }),
          this.autoSettingV
        );
      }),
      (e.prototype.initListData = function () {
        this.resultArr = [];
        for (var t, e = 0; e < this.dataArr.length; e++) {
          var i = this.dataArr[e];
          (t = { item_bang: { text: i.name }, name: i.name, id: i.id }),
            this.resultArr.push(t);
        }
        this.list_autoSettings.dataSource = this.resultArr;
      }),
      (e.prototype.onSettingItemAction = function () {
        this.list_autoSettings.visible = !0;
      }),
      (e.prototype.onListAutoSettingDidClick = function (t) {
        var e = this.list_autoSettings.selectedItem;
        (this.label_SettingItem1.text = e.name),
          (this.list_autoSettings.visible = !1);
      }),
      (e.prototype.onRadioYouXianShiYongAction = function (t) {
        this.radio_youxianshiyong.selectedIndex;
      }),
      (e.prototype.onAutoStartGuaJiAction = function () {
        if (parseInt(this.text_auto_num.text) <= 0)
          ToastView.toastView("请选择挂机次数");
        else {
          var t = parseInt(this.text_auto_num.text);
          if (this.totalNum >= t) {
            localStorage.setItem("autofightTime", this.text_auto_num.text),
              AXProgressBarView.onLoadedRecourse(0);
            var e = this.list_autoSettings.selectedItem,
              i = e.id + ":" + this.radio_youxianshiyong.selectedIndex + ":";
            localStorage.setItem("startAuto", i),
              WebSocketService.send({ c: 500, d: { npcId: e.id } }),
              Laya.stage.event("HomePageView", {
                code: "setAutoFight",
                isAuto: !0,
              }),
              Laya.stage.event("GameMainView", {
                code: "setAutoFight",
                isAuto: !0,
              });
          } else
            ToastView.toastView(
              "对不起，当前您还剩" + this.totalNum + "次挂机。"
            );
        }
      }),
      (e.prototype.onSelectAutoContinue = function () {}),
      (e.prototype.onLoadVipNumberData = function (t) {
        if (0 == t.code) {
          this.totalNum = 0;
          var e = t.data.vipLvl,
            i = 0;
          i =
            e < 0
              ? 50
              : 0 == e
              ? 50
              : 1 == e
              ? 100
              : 2 == e
              ? 150
              : 3 == e
              ? 200
              : 4 == e
              ? 250
              : 99999;
          var o = new Date(),
            n = o.getFullYear() + "-" + (o.getMonth() + 1) + "-" + o.getDate(),
            a = "autofightTimeTotal:" + Global.roleId + ":" + n,
            s = parseInt(localStorage.getItem(a));
          s >= 0 || (s = 0), (this.totalNum = i - s);
        }
      }),
      e
    );
  })(ui.Settings.AutoSettingsDialogUI);
